home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / compuserve-file-archive / 22 Graphics & Utilities / RLESRC.ASC < prev    next >
Encoding:
Text File  |  2019-04-13  |  5.9 KB  |  124 lines

  1. 2
  2. 40:    0c00                   *=   $0c00   ;  starting address
  3. 50:    0c00                   .opt p2
  4.                       ;
  5.                       ; this routine reads a hi-res picture from disk
  6.                       ; and stores it to memory at $2000 on the 128
  7.                       ; copyright (c) 1987 jake lund, sysop on cbmart forum, compuserve
  8.                       ; all rights reserved.
  9.                       ; source and object code uploaded to compuserve with permission
  10.                       ;
  11. 130:   0c00          status   =    144     ;  st is 0 if there's more in the file
  12. 140:   0c00          z1       =    $fb     ;  free zero page location
  13. 150:   0c00          chkin    =    $ffc6   ;  kernal routines
  14. 160:   0c00          chrin    =    $ffcf
  15. 170:   0c00          close    =    $ffc3
  16. 180:   0c00          clrchn   =    $ffcc
  17. 190:   0c00          hires    =    $2000   ;  location of the bitmap
  18.                       ;
  19. 210:   0c00 a9 18             lda  #24
  20. 210:   0c02 8d a9 0c          sta  lines   ; rle pictures are only 192 pixels high (24*8)
  21. 220:   0c05 a2 01             ldx  #1      ;  logical file 1
  22. 230:   0c07 20 c6 ff          jsr  chkin   ;  for input
  23.                       ; lf 1 should have been opened before the sys
  24.                       ;
  25. 260:   0c0a a9 00             lda  #<hires
  26. 260:   0c0c 85 fb             sta  z1
  27. 260:   0c0e a9 20             lda  #>hires
  28. 260:   0c10 85 fc             sta  z1+1    ;  z1 points to the screen
  29. 270:   0c12 a0 00             ldy  #0
  30.                       ;
  31. 290:   0c14 20 a0 0c          jsr  setmask ;  set the mask for $80
  32. 300:   0c17 18                clc  
  33. 310:   0c18          bg       =    *       ;  bg checks for background bits
  34. 320:   0c18 08                php  
  35. 320:   0c19 68                pla  
  36. 320:   0c1a 8d aa 0c          sta  tempp   ;  store the processor status
  37. 330:   0c1d 20 67 0c bg1      jsr  stat    ;  see if there's more in the file
  38. 340:   0c20 20 76 0c          jsr  gchar   ;  get a character
  39. 350:   0c23 f0 1c             beq  fg1     ;  if zero, check for foreground
  40. 360:   0c25 90 46             bcc  split   ;  if <32, we're done
  41.                       ;
  42. 380:   0c27 ad aa 0c          lda  tempp
  43. 380:   0c2a 48                pha  
  44. 380:   0c2b 28                plp          ;  restore .p
  45. 390:   0c2c b0 08             bcs  oop1
  46. 400:   0c2e 4e a8 0c bgloop   lsr  mask    ;  shift the mask right
  47. 410:   0c31 ca                dex          ;  and count down
  48. 420:   0c32 f0 08             beq  fg      ;  if x = 0, go to fg
  49. 430:   0c34 90 f8             bcc  bgloop  ;  keep going if the carry hasn't appeared
  50. 440:   0c36 20 80 0c oop1     jsr  plusy   ;  else move .y up by 8
  51. 450:   0c39 4c 2e 0c          jmp  bgloop
  52.                       ;
  53. 470:   0c3c          fg       =    *       ;  handle the foreground pixels
  54. 480:   0c3c 08                php  
  55. 480:   0c3d 68                pla  
  56. 480:   0c3e 8d aa 0c          sta  tempp   ;  save .p
  57. 490:   0c41 20 67 0c fg1      jsr  stat    ;  check the file status
  58. 500:   0c44 20 76 0c          jsr  gchar   ;  get a character
  59. 510:   0c47 f0 d4             beq  bg1     ;  if zero, back to the background
  60. 520:   0c49 90 22             bcc  split   ;  if a ctrl-code, get out
  61. 530:   0c4b ad aa 0c          lda  tempp
  62. 530:   0c4e 48                pha  
  63. 530:   0c4f 28                plp          ;  restore the carry flag
  64. 540:   0c50 b0 0f             bcs  oop2    ;  if set, fix .y
  65.                       ;
  66. 560:   0c52 b1 fb    fgloop   lda  (z1),y
  67. 560:   0c54 0d a8 0c          ora  mask
  68. 560:   0c57 91 fb             sta  (z1),y  ;  copy the bits from mask to screen
  69. 570:   0c59 4e a8 0c          lsr  mask
  70. 570:   0c5c ca                dex  
  71. 570:   0c5d f0 b9             beq  bg      ;  keep shifting right, until .x is zero
  72. 580:   0c5f 90 f1             bcc  fgloop  ;  keep looping
  73. 590:   0c61 20 80 0c oop2     jsr  plusy   ;  until mask overflows
  74. 600:   0c64 4c 52 0c          jmp  fgloop  ;  but keep looping anyway
  75.                       ;
  76.                       ;  subroutines here
  77.                       ;
  78. 640:   0c67 a5 90    stat     lda  status
  79. 640:   0c69 f0 0a             beq  contin  ;  this is like checking st in basic
  80. 650:   0c6b 68       quit     pla  
  81. 650:   0c6c 68                pla          ;  trash the return address and really quit
  82. 660:   0c6d a9 01    split    lda  #1
  83. 660:   0c6f 20 c3 ff          jsr  close
  84. 660:   0c72 20 cc ff          jsr  clrchn
  85. 670:   0c75 60       contin   rts  
  86.                       ;
  87. 690:   0c76 20 cf ff gchar    jsr  chrin   ;  get a character
  88.                       ; (in rle, codes are allowed to be from 32 to 127)
  89. 710:   0c79 29 7f             and  #127
  90. 710:   0c7b 38                sec  
  91. 710:   0c7c e9 20             sbc  #32     ;  minus 32
  92. 720:   0c7e aa                tax  
  93. 720:   0c7f 60                rts  
  94.                       ;
  95. 740:   0c80 98       plusy    tya  
  96. 740:   0c81 18                clc  
  97. 740:   0c82 69 08             adc  #8
  98. 740:   0c84 a8                tay          ;  add 8 to .y
  99. 750:   0c85 90 19             bcc  setmask ;  clear mask
  100. 760:   0c87 c8       plmore   iny  
  101. 760:   0c88 c0 08             cpy  #8
  102. 760:   0c8a d0 14             bne  setmask
  103. 770:   0c8c a0 00             ldy  #0
  104. 770:   0c8e a9 40             lda  #<320
  105. 770:   0c90 18                clc  
  106. 770:   0c91 65 fb             adc  z1
  107. 770:   0c93 85 fb             sta  z1      ;  add 320
  108. 780:   0c95 a9 01             lda  #>320
  109. 780:   0c97 65 fc             adc  z1+1
  110. 780:   0c99 85 fc             sta  z1+1
  111. 790:   0c9b ce a9 0c          dec  lines
  112. 800:   0c9e f0 cb             beq  quit
  113.                       ;
  114. 820:   0ca0 a9 80    setmask  lda  #128
  115. 820:   0ca2 8d a8 0c          sta  mask
  116. 820:   0ca5 18                clc  
  117. 820:   0ca6 60                rts          ; this bit will eventually overflow
  118.                       ; after enough lsr's
  119.                       ;
  120. 850:   0ca7 60                rts  
  121. 860:   0ca8 00       mask     .byte0       ;  variables
  122. 870:   0ca9 00       lines    .byte0
  123. 880:   0caa 00       tempp    .byte0
  124.